/*
* @Author: Flora
* @Date:   2019-01-17 16:48:08
* @Last Modified by:   Flora
* @Last Modified time: 2019-01-21 12:19:08
*/
var _mm = require('util/mm.js');

var product = {
	getAllProducts : function(resolve, reject){
		_mm.request({
			url 	: _mm.getServerUrl('/list_all_product.do'),
			success : resolve,
			error 	: reject
		});
	},
	getCanBuyProducts : function(resolve, reject){
		_mm.request({
			url 	: _mm.getServerUrl('/list_unbuy.do'),
			success : resolve,
			error 	: reject
		});
	},
	publish : function(data, resolve, reject){
		_mm.request({
			url 	: _mm.getServerUrl('/publish.do'),
			method	: 'POST',
			data 	: data,
			success : resolve,
			error 	: reject
		});
	},
	show : function(productId, resolve, reject){
		_mm.request({
			url 	: _mm.getServerUrl('/show.do'),
			data 	: {
				productId : productId
			},
			method	: 'POST',
			success : resolve,
			error 	: reject
		});
	},
	edit : function(product, resolve, reject){
		_mm.request({
			url 	: _mm.getServerUrl('/edit.do'),
			data 	: product ,
			method	: 'POST',
			success : resolve ,
			error 	: reject
		});
	},
	uploadPic : function(file, resolve, reject){
		_mm.requestFile({
			url		: _mm.getServerUrl('/upload_pic.do'),
			data	: file,
			success	: resolve,
			error	: reject
		})
	},
	delete : function(productId, resolve, reject){
		_mm.request({
			url 	: _mm.getServerUrl('/delete_product.do'),
			data 	: {
					productId : productId
			} ,
			method	: 'POST',
			success : resolve ,
			error 	: reject
		});
	}
};
module.exports = product ;